package com.beaven.beavenime.utils

import android.content.Context
import android.provider.Settings
import android.view.inputmethod.InputMethodManager

/**
 * 当前输入法是否被激活
 */
fun isThisImeEnabled(context: Context, im: InputMethodManager): Boolean {
    var enable = false
    val packageName = context.packageName
    im.enabledInputMethodList.forEach { info ->
        if (packageName == info.packageName) {
            enable = true
        }
    }
    return enable
}

/**
 * 当前输入法是否是启用输入法
 */
fun isThisImeSwitchUse(context: Context): Boolean {
    val method = Settings.Secure.getString(context.contentResolver, Settings.Secure.DEFAULT_INPUT_METHOD)
    return method == INPUT_METHOD_NAME
}